﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Utils;

namespace Cofe.Core.Validater
{
    public class ListActionAttribute : ActionAttribute
    {
        private static Type constructActionType(Type ot)
        {
            Type generic = typeof(IEnumerable<>);
            return generic.MakeGenericType(ot);
        }

        public ListActionAttribute(ActionType at, Type outputType, params string[] parameters)
            : base(at, constructActionType(outputType), parameters)
        {
            if (outputType.IsGenericType() && outputType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
                throw new ArgumentException();

            ItemType = outputType;
        }

    }
}

